JavaScript
{dialog.object}httpFetch Method
Syntax
{dialog.object}.httpFetch(url,onSuccess,onError[,headers]);
Arguments
- urlstring
The URL that contains the data to fetch.
- onSuccessfunction
Function to call when the http request succeeds.
- onErrorfunction
Function to call if the http request fails.
- headersarray of objects
Allows you to set custom headers for the request. headers is an array of objects. Each object has a name and value property.
Description
Fetches data from a specified URL.
Discussion
The .httpFetch() method can be used to fetch data from a remote URL.
The onSuccess callback function is called when the data is available. This function gets called with the data that has been retrieved.
Example:
var url = 'http://some_remote_url'; var cb = function(data) { console.log(data); }; var fail = function() { alert('request failed'); }; {dialog.object}.httpFetch(url,cb,fail);
You can optionally specify headers to include in the request. Headers are defined as an array of objects. For example:
var headers = []; headers.push( { name: 'Authorization', value: 'Bearer my_access_token_value_goes_here' });